<!--
 * @Author: zhangxiangsheng 1026583651@qq.com
 * @Date: 2024-06-24 10:47:30
 * @LastEditors: zhangxiangsheng 1026583651@qq.com
 * @LastEditTime: 2024-06-24 15:38:33
 * @FilePath: \appGly\components\formz\components\yzm.vue
 * @Description: 
 * 
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
-->
<template>
  <view class="">
    <!-- {{data}} -->
    <u-form-item label="预留电话">
      <view class="u-flex" style="flex: 1">
        <u--input :disabled="true" v-model="utelxs" border="none" />
        <wpasssmsbtn ref="code" @click="getcode"></wpasssmsbtn>
      </view>
    </u-form-item>
    <u-form-item :label="item.label" prop="yzm">
      <view class="u-flex" style="flex: 1">
        <u--input v-model="yzm" border="none" />
      </view>
    </u-form-item>
  </view>
</template>

<script>
  export default {
    props: {
      data: {
        type: Object,
        default: () => {
          return {};
        },
      },
      item: {
        type: Object,
        default: () => {
          return {};
        },
      },
      value: {
        type: [String, Number],
        default: () => {
          return "";
        },
      },
    },
    data() {
      return {
        utelxs: "",
        utel: "",
        USearch: {},
        yzm: "",
        WpassSmsfalg: false,
      };
    },
    watch: {
      yzm() {
        this.$emit("input", this.yzm);
      },
    },
    mounted() {
      this.init();
    },
    methods: {
      async codeyz() {
        await this.$refs.code.codeyz(this.yzm);
        // let upw = await this.$store.dispatch("upw/getUpw");
        // console.log(this.$store.state.user);
        // upw.uUser = this.$store.state.user.USearch.uUser
        // if (upw.b_sms != "1") {
        // 	upw.b_sms = "1"
        // }
        // // await this.$z.request("/UPWedt", upw)
        // this.$store.commit("upw/setUpw", {})
        // this.$store.commit("upw/setupwuUser", "")
        // await this.$store.dispatch("upw/getUpw");
        // return
      },
      async init() {
        this.yzm = this.value;
        let USearch = await this.$store.dispatch("user/getuser");
        this.USearch = USearch;
        this.utel = this.USearch.utel;
        if (this.utel && this.utel != "") {
          this.utelxs = `${this.utel.substr(0, 3)}****${this.utel.substr(7)}`;
        }
      },
      getcode() {
        this.WpassSmsfalg = false;
        if (this.utel == "") {
          return;
        }

        this.$refs.code.getCode(this.utel);

        // this.fromdata.codeutel = this.fromdata.utel;
        this.WpassSmsfalg = true;
      },
    },
  };
</script>

<style></style>
